#include <iostream>
using namespace std;

// 虚基类A
class A
{
public:
    int value;
    A(){}
    A(int v):value(v){}
};

class B:virtual public A
{
public:
    B(){}
    B(int a){}
    void showValue()
    {
        cout<<"B继承的A="<<this->B::value<<endl;
    }
};

class C:virtual public A
{
public:
    C(){}
    C(int a){}
    void showValue()
    {
        cout<<"C继承的A="<<this->A::value<<endl;
    }
};

class D:public B,public C
{
public:
    void showSum()
    {
        cout<<"总和为:"<<this->A::value+this->B::A::value+this->C::A::value<<endl;
    }
    D(){}
    D(int a,int b,int c):A(a),B(b),C(c){}
};

int main()
{
    D d1(10,20,30);
    cout<<"A="<<d1.A::value<<endl;
    d1.B::showValue();
    d1.C::showValue();
    d1.showSum();
    return 0;
}